<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>扩展自定义方法</title>
</head>

<body>

    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.1-beta3/mock-min.js"></script>
    <h2>F12打开控制台查看数据，效果更佳</h2>
    <div class="box">
        展示内容:<div id="content"></div>
    </div>
    <script>

        let Random = Mock.Random;

        Random.extend({
            constellations: ['白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座', '水瓶座', '双鱼座'],
            constellation: function (date) {
                return this.pick(this.constellations)//随机挑选一个
            }
        })
        let list_one = Random.constellation()
        // => "水瓶座"
        let list_two = Mock.mock('@CONSTELLATION')
        // => "天蝎座"
        let list_three = Mock.mock({ constellation: '@CONSTELLATION' })
        // => { constellation: "射手座" }

        let list = { list_one, list_two, list_three };


        //展示数据
        console.table(list)
        x = document.getElementById("content");
        //将对象转为JSON
        x.innerHTML = JSON.stringify(list, null, '<br />');


    </script>

</body>

</html>